home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / demos / telecomdemo / dialog.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  5KB  |  148 lines

  1. #ifndef lint
  2. static char SccsId[]= "@(#)dialog.c    V1.7    3/17/95";
  3. #endif
  4.  
  5. /*
  6.  |    File name: dialog.c
  7.  |========================================================================
  8.  |
  9.  |    Copyright (c) 1990 -- V.I. Corporation
  10.  |
  11.  |========================================================================
  12.  */
  13.  
  14. #include "simulate.h"
  15. #include "tlc_fundecl.h"
  16.  
  17.  
  18.  
  19. /*
  20.  *   LoadDialogView -- load the dialog view, get the interesting objects and
  21.  *     create a drawport.
  22.  */
  23. void 
  24. LoadDialogView (viewname)
  25.      char *viewname;
  26. {
  27.   OBJECT drawing;
  28.   OBJECT drawing_limit, point;
  29.   DV_POINT dummy;
  30.  
  31.   Dialog.disp_info.view = TviLoad (viewname);
  32.   drawing = TviGetDrawing (Dialog.disp_info.view);
  33.  
  34.   Dialog.failure_str = TdrGetNamedObject (drawing, "NumFailures");
  35.   Dialog.critical_str = TdrGetNamedObject (drawing, "NumCriticals");
  36.   Dialog.softerror_str = TdrGetNamedObject (drawing, "NumSoftErrors");
  37.   Dialog.node_name_str = TdrGetNamedObject (drawing, "NodeName");
  38.  
  39.   /*
  40.    *   Get the object that defines the part of the drawing to be displayed
  41.    *     and use to clip the drawing and set its position on the screen.
  42.    */
  43.   drawing_limit = TdrGetNamedObject (drawing, "DrawingLimit");
  44.   point = VOobPtGet (drawing_limit, 1);
  45.   VOptGet (point, &Dialog.disp_info.drawing_area.ll, &dummy);
  46.   point = VOobPtGet (drawing_limit, 2);
  47.   VOptGet (point, &Dialog.disp_info.drawing_area.ur, &dummy);
  48.   Dialog.disp_info.virt_pos.ll.x = Dialog.disp_info.drawing_area.ll.x + 16383;
  49.   Dialog.disp_info.virt_pos.ll.y = Dialog.disp_info.drawing_area.ll.y + 16383;
  50.   Dialog.disp_info.virt_pos.ur.x = Dialog.disp_info.drawing_area.ur.x + 16383;
  51.   Dialog.disp_info.virt_pos.ur.y = Dialog.disp_info.drawing_area.ur.y + 16383;
  52.   (VOID) GRvcs_to_scs (&Dialog.disp_info.virt_pos.ll,
  53.                        &Dialog.disp_info.screen_pos.ll);
  54.   (VOID) GRvcs_to_scs (&Dialog.disp_info.virt_pos.ur,
  55.                        &Dialog.disp_info.screen_pos.ur);
  56.  
  57.   Dialog.disp_info.drawport = TdpCreateStretch (StatusScreen,
  58.                                                 Dialog.disp_info.view,
  59.                                            &Dialog.disp_info.virt_pos,
  60.                                       &Dialog.disp_info.drawing_area);
  61.   /*
  62.    *   Initialize the information in the dialog structure.
  63.    */
  64.   Dialog.disp_info.drawn = NO;
  65.   Dialog.disp_info.active = NO;
  66.   Dialog.node_ptr = NULL;
  67.   Dialog.next_view = NULL;
  68. }
  69.  
  70.  
  71. /*
  72.  *   UpdateDialogDrawport -- update the error counters that are represented
  73.  *     by vector text objects.
  74.  */
  75. void UpdateDialogDrawport 
  76. V_P_ ((void))
  77. {
  78.   (VOID) TdpEraseObject (Dialog.disp_info.drawport, Dialog.failure_str);
  79.   SetNumberString (Dialog.failure_str, Dialog.node_ptr->failure_count);
  80.   (VOID) TdpDrawObject (Dialog.disp_info.drawport, Dialog.failure_str);
  81.   (VOID) TdpEraseObject (Dialog.disp_info.drawport, Dialog.critical_str);
  82.   SetNumberString (Dialog.critical_str, Dialog.node_ptr->critical_count);
  83.   (VOID) TdpDrawObject (Dialog.disp_info.drawport, Dialog.critical_str);
  84.   (VOID) TdpEraseObject (Dialog.disp_info.drawport, Dialog.softerror_str);
  85.   SetNumberString (Dialog.softerror_str, Dialog.node_ptr->softerror_count);
  86.   (VOID) TdpDrawObject (Dialog.disp_info.drawport, Dialog.softerror_str);
  87. }
  88.  
  89.  
  90. /*
  91.  *   PickInDialogDrawport -- process picks in the dialog drawport.  The
  92.  *     only actions we're looking for is to go to a subview and to erase
  93.  *     the dialog drawport.
  94.  */
  95. void 
  96. PickInDialogDrawport (location)
  97.      OBJECT location;
  98. {
  99.   CHAR *name;
  100.  
  101.   (VOID) VUerHandleLocEvent (location);
  102.   if ((name = TloGetSelectedObjectName (location)))
  103.     {
  104.       if (strcmp (name, "Detail") == 0)
  105.         if (Dialog.next_view)
  106.           NewMainView (SimParams.curr_view, Dialog.next_view);
  107.       if (strcmp (name, "Quit") == 0)
  108.         EraseSubView (&Dialog.disp_info, (RECTANGLE *) NULL);
  109.     }
  110. }
  111.  
  112.  
  113. /*
  114.  *   SetupDialogBox -- setup the objects in the dialog box using the
  115.  *     information from the node structure.
  116.  */
  117. void 
  118. SetupDialogBox (node_struct, next_view)
  119.      NODE_STRUCT *node_struct;
  120.      VIEW_STRUCT *next_view;
  121. {
  122.   VOvtSetString (Dialog.node_name_str, node_struct->node_name);
  123.   SetNumberString (Dialog.failure_str, node_struct->failure_count);
  124.   SetNumberString (Dialog.critical_str, node_struct->critical_count);
  125.   SetNumberString (Dialog.softerror_str, node_struct->softerror_count);
  126.   Dialog.next_view = next_view;
  127.   Dialog.node_ptr = node_struct;
  128. }
  129.  
  130.  
  131. /*
  132.  *   MoveDialogDrawport -- move the dialog drawport.  Save the original
  133.  *     position, allow the user to move it, and then repair the screen.
  134.  */
  135. void 
  136. MoveDialogDrawport (location)
  137.      OBJECT location;
  138. {
  139.   RECTANGLE old_pos;
  140.  
  141.   old_pos.ll.x = Dialog.disp_info.screen_pos.ll.x;
  142.   old_pos.ll.y = Dialog.disp_info.screen_pos.ll.y;
  143.   old_pos.ur.x = Dialog.disp_info.screen_pos.ur.x;
  144.   old_pos.ur.y = Dialog.disp_info.screen_pos.ur.y;
  145.   MoveDrawport (StatusScreen, &Dialog.disp_info.screen_pos, location);
  146.   NewPosition (&Dialog.disp_info, &old_pos);
  147. }
  148.